﻿<%@ Page Language="C#" MasterPageFile="~/admin/ADAdminLayout.master" AutoEventWireup="true"
    CodeFile="nguoi_dung.aspx.cs" Inherits="admin_nguoi_dung" %>



<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="block" id="block-tables">
        <div class="content">
            <h2 class="title">
                Thành Viên</h2>
            <div class="inner">
                <div class="group">
                    <label>
                        Từ khóa:</label>
                    <asp:TextBox ID="TextBox1" runat="server" class="text_field" size="60"></asp:TextBox>
                    &nbsp;
                    <button class="button slim-button" type="submit">
                        <img src="./images/search.png" alt="Tìm kiếm">
                        Tìm kiếm</button>
                </div>
                <br />
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                    AllowSorting="True"
                    AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSourceThanhVien"
                    CssClass="table" ShowHeaderWhenEmpty="True">
                    <Columns>
                        <asp:TemplateField HeaderText="STT">
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1 %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="ho_ten" HeaderText="Họ tên" SortExpression="ho_ten" />
                        <asp:BoundField DataField="gioi_tinh" HeaderText="Giới tính" SortExpression="gioi_tinh" />
                        <asp:BoundField DataField="so_dt" HeaderText="Số điện thoại" SortExpression="so_dt" />
                        <asp:BoundField DataField="dia_chi" HeaderText="Địa chỉ" SortExpression="dia_chi" />
                        <asp:BoundField DataField="ngay_sinh" HeaderText="Ngày sinh" SortExpression="ngay_sinh" />
                        <asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" />
                        <asp:BoundField DataField="ten_dang_nhap" HeaderText="Tên đăng nhập" SortExpression="ten_dang_nhap" />
                   
                        <asp:CommandField ShowEditButton="True" 
                            EditText="Sửa" UpdateText="Cập nhật" CancelText="Hủy bỏ" ButtonType="Button" ControlStyle-Width = "65px">
                            <ControlStyle Font-Size="Small" />
                        </asp:CommandField>

                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSourceThanhVien" runat="server" ConnectionString="<%$ ConnectionStrings:babydealConnectionString %>"
                    SelectCommand="SELECT id, ho_ten, so_dt, dia_chi, ngay_sinh, email, ten_dang_nhap, mat_khau, nhan_email_quang_cao, gioi_tinh FROM thanh_vien WHERE (ho_ten LIKE '%' + @ho_ten + '%') OR (ten_dang_nhap LIKE '%' + @ten_dang_nhap + '%') OR (dia_chi LIKE '%' + @dia_chi + '%')"
                    DeleteCommand="DELETE FROM [thanh_vien] WHERE [id] = @id" 
                    InsertCommand="INSERT INTO [thanh_vien] ([ho_ten], [so_dt], [dia_chi], [ngay_sinh], [email], [ten_dang_nhap], [mat_khau], [nhan_email_quang_cao], [gioi_tinh]) VALUES (@ho_ten, @so_dt, @dia_chi, @ngay_sinh, @email, @ten_dang_nhap, @mat_khau, @nhan_email_quang_cao, @gioi_tinh)"
                    UpdateCommand="UPDATE [thanh_vien] SET [ho_ten] = @ho_ten, [so_dt] = @so_dt, [dia_chi] = @dia_chi, [ngay_sinh] = @ngay_sinh, [email] = @email, [ten_dang_nhap] = @ten_dang_nhap, [mat_khau] = @mat_khau, [nhan_email_quang_cao] = @nhan_email_quang_cao, [gioi_tinh] = @gioi_tinh WHERE [id] = @id">
                    <DeleteParameters>
                        <asp:Parameter Name="id" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="ho_ten" Type="String"/>
                        <asp:Parameter Name="so_dt" Type="String" />
                        <asp:Parameter Name="dia_chi" Type="String" />
                        <asp:Parameter DbType="Date" Name="ngay_sinh" />
                        <asp:Parameter Name="email" Type="String" />
                        <asp:Parameter Name="ten_dang_nhap" Type="String" />
                        <asp:Parameter Name="mat_khau" Type="String" />
                        <asp:Parameter Name="nhan_email_quang_cao" Type="String" />
                        <asp:Parameter Name="gioi_tinh" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%%" Name="ho_ten" PropertyName="Text"
                            Type="String" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%%" 
                            Name="ten_dang_nhap" PropertyName="Text" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%%" Name="dia_chi" 
                            PropertyName="Text" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="ho_ten" Type="String" />
                        <asp:Parameter Name="so_dt" Type="String" />
                        <asp:Parameter Name="dia_chi" Type="String" />
                        <asp:Parameter DbType="Date" Name="ngay_sinh" />
                        <asp:Parameter Name="email" Type="String" />
                        <asp:Parameter Name="ten_dang_nhap" Type="String" />
                        <asp:Parameter Name="mat_khau" Type="String" />
                        <asp:Parameter Name="nhan_email_quang_cao" Type="String" />
                        <asp:Parameter Name="gioi_tinh" Type="Int32" />
                        <asp:Parameter Name="id" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </div>
        </div>
    </div>

</asp:Content>
